package o;

import android.util.SparseArray;
import androidx.annotation.NonNull;
import com.huawei.appgallery.forum.base.api.IUserStateChange;
import com.huawei.hmf.annotation.ApiDefine;
import com.huawei.hmf.annotation.Singleton;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@ApiDefine(uri = IUserStateChange.class)
@Singleton
public class bry implements IUserStateChange {
    private static final SparseArray<com.huawei.appgallery.forum.base.api.IUserStateChange.d> ˋ = new SparseArray();
    private static ExecutorService ˏ = Executors.newFixedThreadPool(3);

    static class b implements Runnable {
        com.huawei.appgallery.forum.base.api.IUserStateChange.d ˊ;
        int ˏ;

        public b(int i, com.huawei.appgallery.forum.base.api.IUserStateChange.d dVar) {
            this.ˏ = i;
            this.ˊ = dVar;
        }

        public void run() {
            if (this.ˏ == 102) {
                this.ˊ.ॱ(0);
            } else if (this.ˏ == 103) {
                this.ˊ.ॱ(1);
            }
        }
    }

    static class d implements AccountBussinessListener {
        private d() {
        }

        public void onAccountBusinessResult(ccp o_ccp) {
            if (102 == o_ccp.ˎ) {
                bqx.ˊ("UserStateChange", "onAccountBusinessResult, login status: ACCOUNT_LOGIN_SUCCESS");
                bry.ˋ(102);
            } else if (103 == o_ccp.ˎ) {
                bqx.ˊ("UserStateChange", "onAccountBusinessResult, login status: ACCOUNT_LOGOUT_SUCCESS");
                bry.ˋ(103);
            }
        }
    }

    public synchronized void ˊ(@NonNull String str, @NonNull com.huawei.appgallery.forum.base.api.IUserStateChange.d dVar) {
        ˋ.put(str.hashCode(), dVar);
    }

    public synchronized void ॱ(@NonNull String str) {
        ˋ.remove(str.hashCode());
    }

    public static void ˏ() {
        eoj.ˋ().ˎ("UserStateChange", new d());
    }

    private static void ˋ(int i) {
        int size = ˋ.size();
        ArrayList arrayList = new ArrayList();
        for (int i2 = 0; i2 < size; i2++) {
            int keyAt = ˋ.keyAt(i2);
            com.huawei.appgallery.forum.base.api.IUserStateChange.d dVar = (com.huawei.appgallery.forum.base.api.IUserStateChange.d) ˋ.get(keyAt);
            if (dVar != null) {
                ˏ.execute(new b(i, dVar));
            } else {
                arrayList.add(Integer.valueOf(keyAt));
            }
        }
        if (arrayList.size() > 0) {
            synchronized (bry.class) {
                Iterator it = arrayList.iterator();
                while (it.hasNext()) {
                    ˋ.remove(((Integer) it.next()).intValue());
                }
            }
        }
    }
}
